package com.koron.plan.web.patrollineplan.bean.convertor;

import com.koron.bean.plan.patrol.dto.PatrolDto;
import com.koron.bean.plan.patrol.po.PatrolEquipmentItemPo;
import com.koron.bean.plan.patrol.po.PatrolEquipmentParamsPo;
import com.koron.bean.plan.patrol.po.PatrolPo;
import com.koron.bean.plan.patrol.vo.PatrolEquipmentVo;
import com.koron.bean.plan.patrol.vo.PatrolPointVo;
import com.koron.plan.web.patrollineplan.bean.dto.PlanLinePatrolEquipment;
import com.koron.plan.web.patrollineplan.bean.dto.PlanLinePatrolItemDTO;
import com.koron.plan.web.patrollineplan.bean.po.PlanLinePatrol;
import com.koron.plan.web.patrollineplan.bean.po.PlanLinePatrolCheck;
import com.koron.plan.web.patrollineplan.bean.po.PlanLinePatrolRecord;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * @author jzp
 * @since 2022/11/29
 */
@Mapper(componentModel = "spring")
public interface PatrolPlanLineConvertor {

    // PatrolPlanEquipBean equipVOToBean(PlanLinePatrolItemDTO vo);
    //
    // List<PatrolPlanEquipBean> equipVOsToBeans(List<PlanLinePatrolItemDTO> vos);

    @Mappings({
            @Mapping(source = "id", target = "id", ignore = true),
            @Mapping(source = "patrolPointId", target = "planPatrolPointId"),
            @Mapping(source = "patrolPointName", target = "name"),
            @Mapping(source = "createTime", target = "createTime", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true)
    })
    PatrolPointVo pointDetailToOrderPoint(PlanLinePatrolItemDTO detailVO);

    @Mappings({
            @Mapping(source = "id", target = "planId"),
            @Mapping(source = "code", target = "planCode"),
            @Mapping(source = "planDeptId", target = "belongDeptId"),
            @Mapping(source = "planDeptName", target = "belongDeptName"),
            @Mapping(source = "patrolDeptId", target = "patrolDeptId"),
            @Mapping(source = "patrolDeptName", target = "patrolDeptName"),
            @Mapping(source = "staffingWay", target = "arrangement"),
            @Mapping(source = "mustSign", target = "mustSign"),
            @Mapping(source = "arriveWay", target = "arriveWay"),
            @Mapping(source = "patrolCategory", target = "patrolType"),
            @Mapping(source = "readyWork", target = "prepare"),
            @Mapping(source = "remark", target = "remarks"),
            @Mapping(source = "code", target = "code", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true),
            @Mapping(source = "id", target = "id", ignore = true)
    })
    PatrolDto planBasicToOrder(PlanLinePatrol vo);

    @Mappings({
            @Mapping(source = "patrolEquipmentId", target = "equipmentId"),
            @Mapping(source = "patrolPointPositionName", target = "name"),
            @Mapping(source = "checkList", target = "equipmentItemPos"),
            @Mapping(source = "recordList", target = "equipmentParamsPos"),
            @Mapping(source = "id", target = "id", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true)
    })
    PatrolEquipmentVo equipToOrderEquip(PlanLinePatrolItemDTO dto);

    @Mappings({
            @Mapping(source = "patrolPointId", target = "patrolPointId"),
            @Mapping(source = "itemName", target = "checkName"),
            @Mapping(source = "itemContent", target = "standardName"),
            @Mapping(source = "sort", target = "sort"),
            @Mapping(source = "createTime", target = "createTime", ignore = true),
            @Mapping(source = "id", target = "id", ignore = true),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true),
            @Mapping(source = "runState", target = "runState")
    })
    PatrolEquipmentItemPo itemToOrderItem(PlanLinePatrolCheck item);

    List<PatrolEquipmentItemPo> itemsToOrderItems(List<PlanLinePatrolCheck> items);

    @Mappings({
            @Mapping(source = "patrolPointId", target = "patrolPointId"),
            @Mapping(source = "itemName", target = "name"),
            @Mapping(source = "itemUnit", target = "unit"),
            @Mapping(source = "sort", target = "sort"),
            @Mapping(source = "deleteFlag", target = "deleteFlag", ignore = true),
            @Mapping(source = "runState", target = "runState")
    })
    PatrolEquipmentParamsPo recordToParam(PlanLinePatrolRecord record);

    List<PatrolEquipmentParamsPo> recordsToParams(List<PlanLinePatrolRecord> records);

    PatrolPo patrolDtoToPatrolVo(PatrolDto patrolDto);

    @Mappings({
            @Mapping(source = "patrolEquipmentId", target = "equipmentId"),
            @Mapping(source = "patrolPointPositionName", target = "name"),
            @Mapping(source = "id", target = "id", ignore = true)
    })
    PatrolEquipmentVo planEquimToPatrol(PlanLinePatrolEquipment vo);

    List<PatrolEquipmentVo> planEquimToPatrolList(List<PlanLinePatrolEquipment> list);

}
